module SmtpcomApi
  module Helpers

    def to_hash
      self.class.const_get(:ATTRIBUTES).inject({}) do |r, k|
        r.merge k => instance_variable_get("@#{k}")
      end
    end
    alias_method :attributes, :to_hash

    def set_attributes(attributes)
      self.class.const_get(:ATTRIBUTES).each do |k|
        instance_variable_set("@#{k}", attributes[k.to_s])
      end
    end

    def now
      Time.now
    end
  end
end